package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class TestInputStream03 {

    public static void main(String[] args) throws IOException {
        //1.创建输入流
        InputStream input = new FileInputStream("d:\\a.txt");
        //2.读取流中数据
        byte[] bytes = new byte[1024];//1K=1024byte
        int length=0;//长度，从流中读取有效数据的长度
        //read()返回值：int  a.从流中读取数据长度   b.流中没有数据，-1
        while((length=input.read(bytes))!=-1){
            System.out.print(new String(bytes,0,length));
        }
        //3.关闭流
        input.close();
    }
}
